<template>
  <div class="body">
    <div class="login" id="app">
      <div class="sign">登錄</div>
      <img class="weyouth" src="../style/img/weyouth.png">
      <div>
        <input v-model="phone" placeholder="請輸入手機號">
      </div>
      <div class="gray"></div>
      <div>
        <input v-model="password" placeholder="請輸入密碼" type="password">
      </div>
      <div class="gray"></div>
      <button @click="login()">登錄</button>
      <div>
        <div class="forget" @click="toFindPass">忘記密碼</div>
        <div class="Vertical"></div>
        <div class="regis"  @click="register">立即注冊</div>
      </div>
      <div class="other" @click="wxLogin()">
        <div class="pic"></div>
        <div class="mode">其他方式登錄</div>
      </div>
    </div>
  </div>
</template>

<script>
import { login } from '@/api/login'
export default {
  name: 'Login',
  data () {
    return {
      // 17864296101
      // 123456
      phone: '',
      password: ''
    }
  },
  methods: {
    register () {
      this.$router.push('/register')
    },
    toFindPass () {
      this.$router.push('/find_pass')
    },
    login () {
      var phone = this.phone
      var pwd = this.password
      if (phone !== '' && pwd !== '') {
        login({
          phone: this.phone,
          password: this.password
        }).then(response => {
          console.log(response)
          if (response.code === 1) {
            this.$router.push('/')
          } else {
            alert(response.msg)
          }
        }, function (error) {
          console.log(error)
        })
      } else {
        alert('请检查账号密码后重新登录')
      }
    },
    wxLogin: function () {
      // location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8da72d9fb6960d56&redirect_uri=https://weyouth.vip/new/page/index.html&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect'
      location.href = 'https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx8da72d9fb6960d56&redirect_uri=https://weyouth.vip/new/page/index.html&response_type=code&scope=snsapi_userinfo&state=STATE&connect_redirect=1#wechat_redirect'
    }
  }
}
</script>

<style scoped>
* {
  margin: 0;
  padding: 0;
}
/*
TODO: 登陆注册底部背景图
*/
.body {
  background: rgb(255, 255, 255);
  /* background: url(../style/img/copyright.png) no-repeat; */
  /* background-size: cover; */
  font-family: PingFangSC;
  width: 100%;
  height: 1000px;
}

.login {
  width: 80%;
  margin: auto;
  padding-top: 30px;
}

.sign {
  width: 100%;
  text-align: center;
  font-size: 30px;
  margin-bottom: 30px;
}

input {
  font-size: 17px;
}

input::-webkit-input-placeholder {
  font-size: 17px;
  line-height: 44px;
}

.login input {
  line-height: 30px;
  border: none;
  outline: none;
}

.gray {
  margin: 5px 0 20px 0;
  height: 1px;
  background: rgb(212, 212, 212);
}

.input {
  color: gray;
}

button {
  margin: 40px auto 20px auto;
  width: 100%;
  height: 54px;
  border-radius: 30px;
  background: rgb(249, 119, 130);
  background: linear-gradient(to right, rgba(240, 84, 73, 60%),rgba(240, 89, 67, 75%),rgba(237, 56, 99, 70%),rgba(238, 57, 98, 80%),rgba(237, 56, 99, 80%));
  border: none;
  font-size: 24px;
  color: white;
  outline: none;
}

.forget {
  float: left;
  text-align: right;
  width: 40%;
  margin: 0 28px 0 0;
}

.Vertical {
  margin: 3px 0 0 0;
  float: left;
  background: rgb(180, 187, 201);
  height: 20px;
  width: 1px;
}

.regis {
  float: right;
  text-align: left;
  width: 40%;
}

.other {
  overflow: hidden;
  width: 100px;
  height: 100px;
  margin: 100px auto auto auto;
}

.pic {
  margin: 0 30px;
  background: url(../style/img/wxchat.png) no-repeat;
  height: 40px;
  width: 40px;
  background-size: cover;
}

.mode {
  width: 100%;
  text-align: center;
  color: gray;
  margin-top: 1px;
}

.input input {
  float: left;
}

.input span {
  display: inline-block;
  margin-top: -4px;
  margin-left: 4px;
  float: left;
}

.weyouth {
  width: 100px;
  margin-bottom: 10px;
}
</style>
